﻿
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <linux/input.h>

/*
 * ./hs0038_zmq_test /dev/event1
 *
 */

int main(int argc, char **argv)
{

	int fd, ret;
	unsigned char data;
	struct input_event input_event;


	if (argc != 2)
	{
		printf("Usage: %s <dev>\n", argv[0]);
		return -1;
	}
	
	fd = open(argv[1], O_RDWR);
	if (fd == -1)
	{
		printf("Open %s err.\n", argv[1]);
		return -1;
	}
	
	while(1)
	{
			
		if (read(fd, &input_event, sizeof(input_event)) == sizeof(input_event))
		{
			
			printf("get type: %u\n", input_event.type);
			printf("get code: %u\n", input_event.code);
			printf("get value: %d\n", input_event.value);

		}
		else
			printf("get NAN: -1\n");
			
		sleep(1);
	}

	close(fd);
	return 0;
}


